$(function(){

	function alongYaxis(){

	 	var myChart = echarts.init(document.getElementById('main1'));

	    var data = [["2000-06-05",116],["2000-06-06",129],["2000-06-07",135],["2000-06-08",86],["2000-06-09",73],["2000-06-10",85],["2000-06-11",73],["2000-06-12",68],["2000-06-13",92],["2000-06-14",130],["2000-06-15",245],["2000-06-16",139],["2000-06-17",115],["2000-06-18",111],["2000-06-19",309],["2000-06-20",206],["2000-06-21",137],["2000-06-22",128],["2000-06-23",85],["2000-06-24",94],["2000-06-25",71],["2000-06-26",106],["2000-06-27",84],["2000-06-28",93],["2000-06-29",85],["2000-06-30",73],["2000-07-01",83],["2000-07-02",125],["2000-07-03",107],["2000-07-04",82],["2000-07-05",44],["2000-07-06",72],["2000-07-07",106],["2000-07-08",107],["2000-07-09",66],["2000-07-10",91],["2000-07-11",92],["2000-07-12",113],["2000-07-13",107],["2000-07-14",131],["2000-07-15",111],["2000-07-16",64],["2000-07-17",69],["2000-07-18",88],["2000-07-19",77],["2000-07-20",83],["2000-07-21",111],["2000-07-22",57],["2000-07-23",55],["2000-07-24",60]];

		var dateList = data.map(function (item) {
		    return item[0];
		});
		var valueList = data.map(function (item) {
		    return item[1];
		});

	    // 指定图表的配置项和数据
	    option = {
		    // Make gradient line here
		    visualMap: [{
		        show: false,
		        type: 'continuous',
		        seriesIndex: 0,
		        min: 0,
		        max: 400
		    }, {
		        show: false,
		        type: 'continuous',
		        seriesIndex: 1,
		        dimension: 0,
		        min: 0,
		        max: dateList.length - 1
		    }],


		    title: [{
		        left: 'center',
		        text: 'Gradient along the y axis'
		    }, {
		        top: '55%',
		        left: 'center',
		        text: 'Gradient along the x axis'
		    }],
		    tooltip: {
		        trigger: 'axis'
		    },
		    xAxis: [{
		        data: dateList
		    }, {
		        data: dateList,
		        gridIndex: 1
		    }],
		    yAxis: [{
		        splitLine: {show: false}
		    }, {
		        splitLine: {show: false},
		        gridIndex: 1
		    }],
		    grid: [{
		        bottom: '60%'
		    }, {
		        top: '60%'
		    }],
		    series: [{
		        type: 'line',
		        showSymbol: false,
		        data: valueList
		    }, {
		        type: 'line',
		        showSymbol: false,
		        data: valueList,
		        xAxisIndex: 1,
		        yAxisIndex: 1
		    }]
		};

	    // 使用刚指定的配置项和数据显示图表。
	    myChart.setOption(option);
	}

	alongYaxis();
	
   


    function indexLine () {
			var option = {
			    title: {
			        text: ''
			    },
			    tooltip : {
			        trigger: 'axis',
			        axisPointer: {
			            type: 'cross',
			            label: {
			                backgroundColor: '#6a7985'
			            }
			        },
			        backgroundColor: "rgba(255,255,255,1)",//改变提示框的颜色
	            	 textStyle: {
			        	color: "red",
			        	fontWeight: "bold",
			        	fontSize: 16,
			        },
			        formatter:function(params){
			        	console.log(params)
	            		return '<div style="text-align: center;">'+params.data+'</div><span style="color: #4d4d4d;font-size: 14px;text-align: center;">'+params.name+'</span>';
	            	}
			    },
			    // toolbox: {
			    //     feature: {
			    //         saveAsImage: {}
			    //     }
			    // },
			    grid: {
			    	show: false,
			    	height: 175,
			    	top: 100,
			        left: '0%',
			        // right: '4%',
			        // bottom: '0%',
			        containLabel: true,
			    },
			    xAxis : [
			        {
			            type : 'category',
			            boundaryGap : false,
			            data : ['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],
			            axisLabel: {
                            textStyle: {
                                color: '#727ca5'//坐标轴文字的样式
                            }
			            },
			            axisLine: {
			            	lineStyle: {
			            		color: "#727ca5" //坐标轴的样式
			            	}
			            },
			            axisTick: {
			            	show: false,//x 坐标轴 刻度 设置
			            }
			        }
			    ],
			    yAxis : {	
			            type : 'value',
			            splitLine:{
			            	show: false,
			            	lineStyle: {
			            		color: "#727ca5"
			            	}
			            },
			            axisLabel: {
			            	formatter: '{value}',
                            textStyle: {
                                color: '#727ca5'
                            }
			            },
			            axisLine: {
			            	lineStyle: {
			            		color: "transparent" //坐标轴的样式
			            	}
			            }

			    },
			    series : [
			        {
			            name:'邮件营销',
			            type:'line',
			            stack: '总量',
			            smooth:true,  //这句就是让曲线变平滑的  
			            areaStyle: { normal:{
			                color:'rgba(244, 89, 45, 0.1)'//rgba(244, 89, 45, 0.6)
			                
			            }},
			            lineStyle:{
			               normal: {
			                    width:1,  //折线图线条宽度
			                    color:'#000' //颜色
			                    
			                } 
			            },
			            itemStyle : { //折线拐点标志的样式
			                normal: {
			                    label : {show: true},
			                    borderWidth:0,
			                    color:'#000',
			                    opacity: 0
			                    //borderType:'solid',
			                    //shadowColor: 'rgba(0, 0, 0, 0.5)',
			                    //shadowBlur: 10
			                },
			                emphasis: {
			                	color: "#000",
			                	borderWidth: 0,
			                	opacity: 0
			                }
			                
			            },
			            data:[2200, 2000, 2200, 2300, 2400, 2200, 2300],
			            markLine: { //竖线设置
			                name: '',
			                symbolSize:0,
			                lineStyle:{normal:{
			                    
			                    width:0,
			                    type:'solid'
			                }},
			                
			                data: [
			                        [   {
			                                coord: ['Sun', 0]
			                            }, {
			                                coord: ['Sun', 2200]
			                            } 
			                        ],
			                         [   {
			                                coord: ['Mon', 0]
			                            }, {
			                                coord: ['Mon', 2000]
			                            } 
			                        ],
			                        [   {
			                                coord: ['Tue', 0]
			                            }, {
			                                coord: ['Tue', 2200]
			                            } 
			                        ],
			                        [   {
			                                coord: ['Wed', 0]
			                            }, {
			                                coord: ['Wed', 2300]
			                            } 
			                        ],
			                        [   {
			                                coord: ['Thu', 0]
			                            }, {
			                                coord: ['Thu', 2400]
			                            } 
			                        ],
			                        [   {
			                                coord: ['Fri', 0]
			                            }, {
			                                coord: ['Fri', 2200]
			                            } 
			                        ],
			                         [   {
			                                coord: ['Sat', 0]
			                            }, {
			                                coord: ['Sat', 2300]
			                            } 
			                        ]
			                    ]
			            }
			        }
			    ]
			};
			var myChart = echarts.init(document.getElementById("main2"));
			var chartData = echarts.init(main2);
			var app = {};
			chartData.setOption(option,true);
		}
		indexLine();


	function showLIines(){
		var myChart = echarts.init(document.getElementById('main3'));
		 // 指定图表的配置项和数据
	    option = {
		    title: {
		    	show: false,
		        text: ''
		    },
		    tooltip: {
		        trigger: 'axis'
		    },
		    legend: {
		    	show: false,
		        data:['邮件营销','联盟广告','视频广告','直接访问','搜索引擎']
		    },
		    grid: {
		        left: '3%',
		        right: '4%',
		        bottom: '3%',
		        containLabel: true
		    },
		    // toolbox: {
		    //     feature: {
		    //         saveAsImage: {}
		    //     }
		    // },
		    xAxis: {
		        type: 'category',
		        boundaryGap: true,
		        data: ['周一','周二','周三','周四','周五','周六','周日'],
		        axisLabel: {
                    textStyle: {
                        color: '#fff'//坐标轴文字的样式
                    },
                    align: "center"
	            },
	            axisLine: {
	            	lineStyle: {
	            		color: "#ccc" //坐标轴的样式
	            	}
	            },
	            axisTick: {
	            	show: false,//x 坐标轴 刻度 设置

	            },
	            // axisTick: {
	            // 	alignWithLabel: true
	            // },
		    },
		    yAxis: {
		        type: 'value',
		        // right: "10px",
		        splitLine:{
	            	show: true,
	            	lineStyle: {
	            		color: "#ccc",//横向分割线的 样式
	            	}
	            },
	            axisLabel: {
	            	formatter: '{value}',
	                textStyle: {
	                    color: '#fff'
	                },
	                // align: 'center'
	            },
	            axisLine: {
	            	lineStyle: {
	            		color: "transparent" //坐标轴的样式
	            	}
	            },
		    },
		    series: [
		        {
		            name:'邮件营销',
		            type:'line',
		            stack: '总量',
		            smooth: true,
		            data:[120, 132, 101, 134, 90, 230, 210],
		            itemStyle : { //折线拐点标志的样式
		                normal: {
		                    opacity: 0
		                },
		                emphasis: {
		                	opacity: 0
		                }
		                
		            },
		        },
		        {
		            name:'联盟广告',
		            type:'line',
		            stack: '总量',
		            smooth: true,
		            data:[220, 182, 191, 234, 290, 330, 310],
		            itemStyle : { //折线拐点标志的样式
		                normal: {
		                    opacity: 0
		                },
		                emphasis: {
		                	opacity: 0
		                }
		                
		            },
		        },
		        {
		            name:'视频广告',
		            type:'line',
		            stack: '总量',
		            smooth: true,
		            data:[150, 232, 201, 154, 190, 330, 410],
		            itemStyle : { //折线拐点标志的样式
		                normal: {
		                    opacity: 0
		                },
		                emphasis: {
		                	opacity: 0
		                }
		                
		            },
		        },
		        {
		            name:'直接访问',
		            type:'line',
		            stack: '总量',
		            smooth: true,
		            data:[320, 332, 301, 334, 390, 330, 320],
		            itemStyle : { //折线拐点标志的样式
		                normal: {
		                    opacity: 0
		                },
		                emphasis: {
		                	opacity: 0
		                }
		                
		            },
		        },
		        {
		            name:'搜索引擎',
		            type:'line',
		            stack: '总量',
		            smooth: true,
		            data:[820, 932, 901, 934, 1290, 1330, 1320],
		            itemStyle : { //折线拐点标志的样式
		                normal: {
		                    opacity: 0
		                },
		                emphasis: {
		                	opacity: 0
		                }
		                
		            },
		        }
		    ]
		};

	    // 使用刚指定的配置项和数据显示图表。
	    myChart.setOption(option);
	}
	showLIines();
})
var mortise_layout={};
mortise_layout.Data={uid:""}


//ajax结果返回值验证，结果为空或失去登录或访问没有权限都会返回false，内部已做好弹出层提示
/**
 * 请求结果验证
 * @param data 服务器返回的数据
 * @param extNote 是否对除未登录、权限不足以外的验证做出提示，true表示自己进行提示，不传或false表示系统自动提示
 * @returns {boolean} true验证通过 false验证失败
 * @constructor
 */
mortise_layout.ValidataResult=function (data,extNote) {
    if(!data||data==""){
        return false;
    }else if(data.code=="NoRule"){
        alert('您没有访问该数据的权限！');
        return false;

    }else if(data.code=='NoLogin'||data.code=='LoginFail'){
        alert('您已失去登录状态！请重新登录系统！');
        window.location.href='/login2'
        return false;
    }else if(data.code=="ServiceError"&&!extNote){
        alert('服务器暂时繁忙，请联系工作人员！')
        return false;

    }else if(data.code=="ParamsError"&&!extNote){
        var errmsg="请求的参数不正确！" + (data.errorMsg?data.errorMsg:"");
        alert('访问失败');
        return false;

    }else{
        return true;
    }
}
